package com.ethan.androidroom;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.annotations.NonNull;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.ObservableEmitter;
import io.reactivex.rxjava3.core.ObservableOnSubscribe;
import io.reactivex.rxjava3.core.Scheduler;
import io.reactivex.rxjava3.schedulers.Schedulers;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        findViewById(R.id.add).setOnClickListener(v -> {
            User user = new User();
            user.firstName = "12121";
            user.lastName = "12121";
            User user1 = new User();
            user.firstName = "12121";
            user.lastName = "12121";
            AppDatabase appDatabase = AppDatabase.getInstance(this, new AppExecutors());
            Observable.just(appDatabase.userDao().insertAll(user))
            .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(f -> {
                        System.out.println("插入成功---" + f);

                    });


        });

        findViewById(R.id.del).setOnClickListener(v -> {

        });

        findViewById(R.id.edit).setOnClickListener(v -> {

        });
    }
}